package com.leonzhangxf.springdatastudy.repo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Embedded;

import java.util.Date;

/**
 * @author leonzhangxf
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AuditData {

    @CreatedDate
    @Column("created")
    private Date created;

    @LastModifiedDate
    @Column("modified")
    private Date modified;

    @CreatedBy
    @Embedded.Nullable(prefix = "creator_")
    private User creator;

    @LastModifiedBy
    @Embedded.Nullable(prefix = "modifier_")
    private User modifier;
}
